package io.bsly.modules.app.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.bsly.common.utils.PageUtils;
import io.bsly.common.utils.R;
import io.bsly.modules.app.entity.localEntity.DyOfficalOrderEntity;
import io.bsly.modules.app.service.localmaster.DyOfficalOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 抖音官方订单
 *
 * @author fys
 * @email demo@gmail.com
 * @date 2021-10-25 09:57:05
 */
@RestController
@RequestMapping("app/dyofficalorder")
public class DyOfficalOrderController {
    @Autowired
    private DyOfficalOrderService dyOfficalOrderService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = dyOfficalOrderService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{couponNo}")
    public R infoByCoupenNo(@PathVariable("couponNo") String coupenNo){
        DyOfficalOrderEntity dyOfficalOrder = dyOfficalOrderService.getByCouponNo(coupenNo);
        return R.ok().put("dyOfficalOrder", dyOfficalOrder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DyOfficalOrderEntity dyOfficalOrder){
		dyOfficalOrderService.save(dyOfficalOrder);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DyOfficalOrderEntity dyOfficalOrder){
		dyOfficalOrderService.updateById(dyOfficalOrder);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		dyOfficalOrderService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
